/*
 * Array.h
 *
 *  Created on: 2011-7-22
 *      Author: gexiao
 */
/*
 * Array handling.
 */
#ifndef ARRAY_H_
#define ARRAY_H_

/*
 * Find a matching array class. If it doesn't exist, create it.
 *
 * "descriptor" looks like "[I".
 *
 * "loader" should be the defining class loader for the elements held
 * in the array.
 */
ClassObject* dvmFindArrayClass(const char* descriptor, Object* loader);

/*
 *
 */
ArrayObject* dvmAllocArrayByClass(ClassObject* arrayClass, size_t length,
		int allocFlags);

/*
 *
 */
ArrayObject* dvmAllocPrimitiveArray(char type, size_t length, int allocFlags);

/*
 * Verify that the class is an array class.
 *
 * TODO: there may be some performance advantage to setting a flag in
 * the accessFlags field instead of chasing into the name string.
 */
INLINE bool dvmIsArrayClass(const ClassObject* clazz) {
	return (clazz->descriptor[0] == '[');
}

#endif /* ARRAY_H_ */
